package com.auth.custom;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import utils.Md5Utils;

/**
 * @Author:Tangjiachang
 * @Date 2023/7/16
 * @Description:
 */
@Component
public class CustomMd5PasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        return Md5Utils.encrypt(charSequence.toString());
    }

    @Override
    public boolean matches(CharSequence charSequence, String encodePassword) {
        return encodePassword.equals(Md5Utils.encrypt(charSequence.toString()));
    }
}
